# 1、以下代码的输出结果是____20_____
# class Student:
#     age = 20
# s1 = Student()
# s1.age = 50
# s2 = Student()
# print(s2.age)

# 2、以下代码的输出结果是____50____
# class Student:
#     age = 20
# s1 = Student()
# Student.age = 50
# print(s1.age)

# 3、以下代码的输出结果是_____18_____
# class Student:
# 	age = 20
# 	def __init__(self,age):
# 	    Student.age = age
# s2 = Student(18)
# print(s2.age)

# 4、以下代码的输出结果是____姓名:张三	年龄：28 _____
# class Student:
#     def __init__(self,name,age):
#         self.age = age
#         self.name = name
#     def info(self):
#         print(f'姓名:{self.name}\t年龄：{self.age}')
# s1 = Student('张三',28)
# s1.info()

# 5、以下代码的输出结果是____True_____
class A():
    __instance = None
    def __new__(cls,*args,**kwargs):
        if not A.__instance:
            A.__instance = object.__new__(cls)
        return A.__instance

    # def __init__(self,n,a):
    #     self.name=n
    #     self.age=a
a=A()
b=A()
# a = A('张三',18)
# b = A('李四',19)
# print(f'a----{a.name}')
# print(f'b----{b.name}')
print(a is b)

# 6、以下代码的输出结果是___1001______
# class School:
#     num = 1000
#     @classmethod
#     def update(cls,n):
#         cls.num += n
# class Student:
#     def __init__(self,name,age):
#         self.age = age
#         self.name = name
#         School.update(1)
#     def info(self):
#         print(f'姓名:{self.name}\t年龄：{self.age}')
# s1 = Student('张三',28)
# print(School.num)

# 7、以下代码的输出结果是____结束啦____
# class School:
#     num = 1000
#     @classmethod
#     def update(cls,n):
#         cls.num += n
# class Student:
#     def __init__(self,name,age):
#         self.age = age
#         self.name = name
#         School.update(1)
#     def __del__(self):
#         print('结束啦')
# s1 = Student('张三',28)
#
# 8、以下代码的输出结果是___Exception: 子类必须实现此方法_______
# class Animal:
#     def move(self):
#         raise Exception('子类必须实现此方法')
# class Dog(Animal):
#     pass
# dog = Dog()
# dog.move()

# 9、以下代码的输出结果是___二哈跑跑跑_____
# class Animal:
#     def __init__(self,name,age):
#         self.name,self.age = name,age
# def move(self):
#     raise Exception('子类必须实现此方法')
# class Dog(Animal):
#     def move(self):
#         print(f'{self.name}跑跑跑')
# dog = Dog('二哈',5)
# dog.move()

# 10、以下代码的输出结果是____李四的年龄是31，手机号是13512345678_____
# class Member:
#     __name,__age,__phone = '张三' , 20 , '18512345678'
#     def set(self,n,a,p):
#         Member.__name = n
#         Member.__age = a
#         Member.__phone = p
#     def get(self):
#         print(f'{self.__name}的年龄是{self.__age}，手机号是{self.__phone}')
# m = Member()
# m.set('李四',31,'13512345678')
# m.get()

# 11、以下代码的输出结果是___哼~哼~~哼~~~_____
# class Dog:
#     def voice(self):
#         print('汪~汪~~汪~~~')
# class Pig:
#     def voice(self):
#         print('哼~哼~~哼~~~')
# class People:
#     def voice(self):
#         print('哇~呀~~呀~~~')
# def func(obj):
#     obj.voice()
# if __name__ == '__main__':
#     dog,pig,people = Dog(),Pig(),People()
#     func(pig)



"""
1、编写一个类My_Len，作用与len(obj)相同，即可以统计对象的元素个数。如果被统计的对象是整数或者小数则报错.
"""
# class My_len(object):
#     def my_len(self,object):
#         count = 0
#         try:
#             for i in object:
#                 count += 1
#             print(count)
#         except:
#             print('检查统计对象是否是整数或小数')
#
# if __name__ == '__main__':
#     a=My_len()
#     a.my_len(2.5)

# class My_len(object):
#     @classmethod
#     def show_count(cls,obj):
#         count=0
#         if isinstance(obj,(int,float)):
#             raise TypeError("被统计的对象是整数或者小数")
#         for i in obj:
#             count+=1
#         return count
# print(My_len.show_count("123"))

"""
2、实现自助查询机(登录、查询、退出功能)，自助取款机(登录、查询、取款、退出功能)，自助存取款机
    (登录、查询、取款、存款、退出功能)，只需要将方法声明出来即可，方法体不写。随机生成一台机器，
    提供与机器相对应的服务选择界面（比如生成的是取款机，则登录成功后显示查询、取款、退出选项）
"""
# import random
# class Query(object):
#     def login(self):
#         pass
#     def qurey(self):
#         pass
#     def exit(self):
#         pass
# class Get(Query):
#     def get(self):
#         pass
# class ATM(Get):
#     def save(self):
#         pass
# class Menu(object):
#     def menu(self,option):
#         if option == 1:
#             Query().login()
#         elif option == 2:
#             Get().login()
#         elif option == 3:
#             ATM().login()
#
# if __name__ == '__main__':
#     a = Menu().menu(random.randint(1,3))

# import random
# class Machine(object):
#     def login(self):
#         print("登录".center(30, "*"))
#     def query(self):
#         print("查询".center(30, "*"))
#     def logout(self):
#         print("退出".center(30, "*"))
# class Query_Machine(Machine):
#     pass
# class Cash_Out_Machine(Machine):
#     def cash_out(self):
#         print("取款".center(30, "*"))
# class Cash_Out_In_Machine(Cash_Out_Machine):
#     def cash_in(self):
#         print("存款".center(30, "*"))
# random_machine = random.choice((Query_Machine(), Cash_Out_Machine(), Cash_Out_In_Machine()))
# print(random_machine)







